package top.hkyzf.study.leetcode.string;

import org.junit.Test;

/**
 * @author zhufeng
 * @version 1.0
 * @date 2022-2-27 20:20
 */
public class 最优除法_553 {
    public String optimalDivision(int[] nums) {
        if (nums.length == 1) {
            return String.valueOf(nums[0]);
        } else if (nums.length == 2) {
            return nums[0] + "/" + nums[1];
        } else {
            StringBuilder result = new StringBuilder(nums[0] + "/(");
            for (int i = 1; i < nums.length; i++) {
                if (i == nums.length-1) {
                    result.append(nums[i]).append(")");
                } else {
                    result.append(nums[i]).append("/");
                }
            }
            return result.toString();
        }
    }

    @Test
    public void testOptimalDivision () {
        int[] nums = {1000,100,10,2};
        System.out.println(optimalDivision(nums));
    }
}
